import React, { Component } from 'react'
import DBForm from '../DBForm'
import DBTable from '../DBTable'

class DBData extends Component {
  state = {
    pageSize: 0
  }
  componentWillMount() {
  }
  parentProps = (pageSize) => {
    this.setState({pageSize})
  }

  render() {
    const {type} = this.props.match.params;
    return (
      <div className="form-container">
        {
          type === 'single' 
          ?
          <div className="single-form-conainer">
            <DBForm type={type} /> 
          </div>
          : 
          <div className="list-form-container">
            <DBForm dbtalePageSize={this.state.pageSize}/>
            <DBTable parentProps={this.parentProps}/>
          </div>
        }
      </div>
    )
  }
}
export default DBData
